<template>
  <div class="carousel-container">
    <div class="carousel-wrapper">
      <el-carousel indicator-position="none">
        <el-carousel-item v-for="(item, index) in imagelist" :key="index">
          <img :src="item.imageUrl" alt="" />
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>
  <script>
export default {
  // eslint-disable-next-line vue/multi-word-component-names
  name: 'carousel',
  data() {
    return {
      imagelist: []
    }
  },
  created() {
    this.getImages()
  },
  methods: {
    // 获取图片
    async getImages() {
      const { data: res } = await this.$axios.get('/images/select')
      console.log(res)
      this.imagelist = res.data.images
    }
  }
}
</script>
<style lang="less" scoped>
.carousel-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.carousel-wrapper {
  max-width: 800px;
  width: 100%;
}

.carousel-wrapper img {
  width: 100%;
  height: 300px; /* 设置图片高度 */
  object-fit: cover; /* 图片填充方式 */
}

.el-carousel__item {
  text-align: center;
}
</style>
